<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>validator</title>
    <script type="text/javascript" src="dist/validator.js"></script>
<script type="text/javascript">
  var data = {
    test: '60',
    info: 'abc',
    abba: 'abba'
  }
  // 添加回文规则
  validator.pushRule('palindromic', function (val, rval) {
    if (rval) {
      console.log(val.split('').reverse())
      return val.split('').reverse().join('') === val
    }
    return true
  })
  // console.log(validator)
  var valid = validator.validate(data, {
    name: {
      required: false, msg: 'xxx'
    },
    abba: {
      palindromic: false, msg: '必须是回文数'
    },
    commit: {required: false, length: 123, msg: 'commit len 123'},
    test: {between: [50, 100], msg: '必须 50 ~ 100'},
    nickname: {eq: 123, msg: 'val 123'},
    info: [{type: String, length: [2, 5], msg: 'length err'}, {eq: '123', msg: 'value = 123'}]
  })

  console.log('验证结果：', !valid.fails())
  console.log(valid.first())
  console.log(valid.all())
  console.log(valid.valider())

  console.log(validator.Rule.between(50, [12, 60]))

</script>
</head>
<body>
    
</body>
</html>